package com.zeng.ssm.controller;

import com.zeng.ssm.api.SysUserService;
import com.zeng.ssm.dal.model.SysUser;
import com.zeng.ssm.service.util.ApplicationContextUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.sql.DataSource;
import java.util.List;

/**
 * 描述信息
 *
 * @author zengwanlin
 * @date 2022-01-27T10:16
 */
@Controller
public class HelloController {

    @Resource
    private SysUserService sysUserService;

    @GetMapping("/users")
    @ResponseBody
    public List<SysUser> findAll() {
        return sysUserService.findAll();
    }

    @GetMapping("/beans")
    @ResponseBody
    public String[] beans() {
        String[] beanNamesForType = ApplicationContextUtil.getApplicationContext().getBeanNamesForType(DataSource.class);
        return beanNamesForType;
    }

    @GetMapping("/hello")
    @ResponseBody
    public String hello() {
        return "Hello SSM2";
    }

}
